package com.smartao.base.setting;

import java.util.List;

import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.smartao.core.dao.BaseEntityDao;

@Repository
public class SettingDaoImpl extends BaseEntityDao<Setting, Long> implements SettingDao{

	@Override
	public Setting findByKey(String key) {
		return findUnique(Restrictions.eq("settingKey", key));
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Setting> findByModule(Long moduleId) {
		String hql = "FROM Setting where module.id=:moduleId";
		return getSession().createQuery(hql)
				.setLong("moduleId", moduleId)
				.list();
	}

}
